******			
****This code replicates the models in the paper "Is It the Economy or Foreign Policy, Stupid? The Impact of Foreign Crises on Leader Support", by Jaroslav Tir and Shane P. Singh, which appears in Comparative Politics. 
******	

use "/xxxxx/CSES Module 2, Tir and Singh CP.dta"

***
*Define estimation sample
***
reg ICB foreignmostimp votedinc  highapprov educ unemploy_t unemployed distanceinc age 
gen samp = 1 if e(sample)


***
*Summary stats
***
sum foreignmostimp votedinc highapprov educ unemploy_t unemployed distanceinc age if samp == 1

***
*Table 2
***
tab countryandyear if samp == 1


***
*Table 3 and associated discussion
***
reg foreignmostimp ICB if samp==1 //*The proportion of individuals identifying foreign policy issues as most important nearly doubles from 0.057 to 0.102 ( p < .001) in countries that are involved in a foreign policy crisis, as compared to those that are not.
margins, over(ICB)

xtlogit foreignmostimp ICB  if samp==1, i(cntryyearnum)   intpoints(4) //*Model 1

***
*Discussion on top of page 92
***
*Mean incumbent voting and mean incumbent approval are both substantially higher in countries involved in an international crisis, as compared to those that are not. The proportion of the electorate voting for the incumbent rises from 0.310 to 0.398 and the proportion approving of the incumbent rises from 0.510 to 0.575; both differences are significant, p < .001.
reg votedinc ICB if samp==1 
margins, over(ICB)

reg highapprov ICB if samp==1 
margins, over(ICB)

***
*Table 4 and associated discussion
***
*The standard deviation of the unemployment variable is 4.09 across countries. 
preserve
keep if samp == 1
collapse unemploy_t, by(country)
sum unemploy_t
restore

xtlogit votedinc ICB unemploy_t unemployed  distanceinc age educ if samp==1, i(cntryyearnum) intmethod(ghermite) //*Model 2
margins, dydx(*)  predict(pu0) coeflegend atmeans post //*Individuals residing in countries involved in an international crisis are 9.9 percentage points more likely to vote for the incumbent
di 4.09*_b[unemploy_t] //*A positive standard deviation difference in the unemployment rate is associated with a decrease in the likelihood that one will vote for the incumbent of 9.2 percentage points.
test _b[ICB] = 4.09*_b[unemploy_t] //... the differences in the effects are significant at p < .01 for both incumbent voting and incumbent approval.

xtlogit votedinc c.ICB##c.unemployed unemploy_t distanceinc age educ if samp==1, i(cntryyearnum) intmethod(ghermite) //*Model 3

xtlogit highapprov ICB unemploy_t unemployed  distanceinc age educ if samp==1, i(cntryyearnum) intmethod(ghermite) //*Model 4
margins, dydx(*) predict(pu0) coeflegend atmeans post //*Individuals residing in countries involved in an international crisis are... 7.2 percentage points more likely to approve of the incumbent.
di 4.09*_b[unemploy_t] //*In terms of incumbent approval, the associated value is a decrease of 11.1 percentage points.
test _b[ICB] = 4.09*_b[unemploy_t] //*... the differences in the effects are significant at p < .01 for both incumbent voting and incumbent approval.

xtlogit highapprov c.ICB##c.unemployed unemploy_t distanceinc age educ if samp==1, i(cntryyearnum) intmethod(ghermite) //*Model 5


***
*Table 5 and associated discussion
***
*Upper-left quadrant
xtlogit votedinc c.ICB##c.unemployed unemploy_t distanceinc age educ if samp==1, i(cntryyearnum) intmethod(ghermite) //*Model 3
margins, predict(pu0) dydx(ICB) at(unemployed = (0 1)) atmeans post coeflegend //*The results indicate that a country�s involvement in an international crisis is associated with a positive 7.7 percentage point difference in the likelihood of voting for the incumbent among those who are employed and a positive 10 percentage point difference among the unemployed.
test  _b[1bn._at] =  _b[2._at] //*...though the differences in the values are not statistically significant. 

*Upper-right quadrant
xtlogit highapprov c.ICB##c.unemployed unemploy_t distanceinc age educ if samp==1, i(cntryyearnum) intmethod(ghermite) //*Model 5
margins, predict(pu0) dydx(ICB) at(unemployed = (0 1)) atmeans post coeflegend //*...the likelihood of approval is 12.4 percentage points higher in countries with a foreign crisis among the unemployed and 11.2 percentage points higher among the employed.
test  _b[1bn._at] =  _b[2._at] //*these values are again statistically indistinguishable

*Lower-left quadrant
xtlogit votedinc c.ICB##c.foreignmostimp unemploy_t unemployed distanceinc age educ if samp==1, i(cntryyearnum) intmethod(ghermite) //*Model 7
margins, predict(pu0) dydx(ICB) at(foreignmostimp = (0 1)) atmeans //*...among those who are not most concerned with international affairs, a country�s involvement in an international crisis is associated with a 6.6 percentage point increase in the likelihood of voting for the incumbent. Meanwhile, for those who are most concerned with foreign policy, such involvement does not have a significant effect.

*Lower-right quadrant
xtlogit highapprov c.ICB##c.foreignmostimp unemploy_t unemployed distanceinc age educ if samp==1, i(cntryyearnum) intmethod(ghermite) //*Model 9
margins, predict(pu0) dydx(ICB) at(foreignmostimp = (0 1)) atmeans //*...among those who are not most concerned with international affairs, a country�s involvement in an international crisis is associated with an 11.9 percentage point increase in the likelihood of approving of the incumbent. For those who are most concerned with foreign policy, such involvement is still positively related to incumbent approval, though the magnitude of the relationship is less, at 6.4 percentage points. 


***
*Table 6
***
xtlogit votedinc ICB foreignmostimp unemploy_t unemployed distanceinc age educ if samp==1, i(cntryyearnum) intmethod(ghermite) //*Model 6

xtlogit votedinc c.ICB##c.foreignmostimp unemploy_t unemployed distanceinc age educ if samp==1, i(cntryyearnum) intmethod(ghermite) //*Model 7

xtlogit highapprov ICB foreignmostimp unemploy_t unemployed distanceinc age educ if samp==1, i(cntryyearnum) intmethod(ghermite) //*Model 8

xtlogit highapprov c.ICB##c.foreignmostimp unemploy_t unemployed distanceinc age educ if samp==1, i(cntryyearnum) intmethod(ghermite) //*Model 9




